package defense.graphics;

import java.awt.Graphics2D;
import java.util.ArrayList;

import defense.GameObject;

public class ParticleEffect extends GameObject {
	ArrayList<Particle> particles;

	public ParticleEffect() {
		particles = new ArrayList<Particle>();
	}

	public void update() {
		for (int i = 0; i < particles.size(); i++) {
			Particle p = particles.get(i);
			p.update();
			if (p.isDead())
				particles.remove(i--);
		}
	}
	
	public boolean isDead() {
		return particles.isEmpty();
	}

	public void display(Graphics2D g2d) {
		for (int i = 0; i < particles.size(); i++) {
			particles.get(i).display(g2d);
		}
	}

	public void addParticle(Particle p) {
		particles.add(p);
	}
}
